package com.wcy.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.util.List;

import com.wcy.annotation.pageVo.MappingColumn;
import com.wcy.annotation.pageVo.PageColumn;
import com.wcy.annotation.pageVo.PageName;
import com.wcy.annotation.pageVo.SelectionAnnotation;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
/**
 * <p>
 * 
 * </p>
 *
 * @author 吴传亿
 * @since 2025-04-27
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@TableName("learning_resource")
@PageName(name = "学习资源")
public class LearningResource {

    @PageColumn(isId = true,prop="resourceId", label="资源ID",allowEdit = false)
    @TableId(value = "resource_id", type = IdType.AUTO)
    private Integer resourceId;

    @PageColumn(prop="imgPath", label="资源图片", type="img", url="resource/upload",fetchUrl = "resource/download/")
    @TableField("img_path")
    private String imgPath;

    @PageColumn(prop="title", label="资源名")
    @TableField("title")
    private String title;

    @PageColumn(prop="description", label="资源描述", type="textarea")
    @TableField("description")
    private String description;

    @PageColumn(prop="content", label="资源内容", type="textarea")
    @TableField("content")
    private String content;

    @PageColumn(prop="categoryId", label="资源分类", type="select",selectRef = @SelectionAnnotation(apiUrl = "category/list",mapProp = "categoryId",mapLabel = "categoryName"))
    @TableField("category_id")
    private Integer categoryId;

    @PageColumn(prop="authorId", label="作者ID",type = "select",selectRef = @SelectionAnnotation(apiUrl = "user/list",mapProp = "userId",mapLabel = "username"))
    @TableField("author_id")
    private Integer authorId;

    @PageColumn(prop="createdAt", label="创建时间",type = "date-picker",display = false)
    @TableField("created_at")
    private LocalDateTime createdAt;

    @PageColumn(prop="updatedAt", label="更新时间",type = "date-picker",display = false)
    @TableField("updated_at")
    private LocalDateTime updatedAt;

    @PageColumn(prop="tags", label="标签",type = "mapping",mappingRef = @MappingColumn(targetProp = "resourceId",mappingByPropUrl = "resourceTagMapping/list",mappingListUrl = "resourceTag/list",mappingListProp = "tagId",mappingListLabel = "tagName"))
    @TableField(exist = false)
    private List<ResourceTag> tags;
}
